//
//  GRBargainCell.m
//  YC_GRice
//
//  Created by luojinrong11 on 2019/4/16.
//  Copyright © 2019年 YeCai. All rights reserved.
//

#import "GRBargainCell.h"

@implementation GRBargainCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
 
}

-(void)setHanggleModel:(GRHagleGoodModel *)hanggleModel{
    _hanggleModel = hanggleModel;
    self.nameLabel.text = hanggleModel.title;
    [self.viewPointBt setTitle:[NSString stringWithFormat:@"%ld",hanggleModel.viewCount] forState:UIControlStateNormal];
    if (hanggleModel.stock == 0) {
        self.giveNumLabel.text = [NSString stringWithFormat:@"%ld件已砍光",(long)hanggleModel.successCount];
        [self.barginBt setTitle:@"已砍光" forState:UIControlStateNormal];
         self.barginBt.backgroundColor = HEXCOLOR(0xDDDDDD);
        [self.barginBt setTitleColor:HEXCOLOR(0x666666) forState:UIControlStateNormal];
        self.barginBt.userInteractionEnabled = NO;
    }else{
          self.giveNumLabel.text = [NSString stringWithFormat:@"已送出%ld件",(long)hanggleModel.successCount];
        if (hanggleModel.hasHaggle) {
             self.giveNumLabel.text = [NSString stringWithFormat:@"%ld件正在砍",(long)hanggleModel.successCount];
            [self.barginBt setTitle:@"已砍过" forState:UIControlStateNormal];
            self.barginBt.backgroundColor = HEXCOLOR(0xDDDDDD);
            [self.barginBt setTitleColor:HEXCOLOR(0x666666) forState:UIControlStateNormal];
            self.barginBt.userInteractionEnabled = NO;
        }else{
                self.giveNumLabel.text = [NSString stringWithFormat:@"%ld人正在看",(long)hanggleModel.successCount];
            self.barginBt.userInteractionEnabled = YES;
             [self.barginBt setTitle:@"点击免费拿" forState:UIControlStateNormal];
            self.barginBt.backgroundColor = HEXCOLOR(0xFF331F);
      
            [self.barginBt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        }
    }
  
    [self.goodImageView sd_setImageWithURL:[NSURL URLWithString:hanggleModel.mainPhoto] placeholderImage:[UIImage imageNamed:@""]];
   
}

- (IBAction)hangleGoodAction:(UIButton *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(hanglAction:)]) {
        [_delegate hanglAction:self.hanggleModel.id];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
